% 
% @(#)Bitchunk.m	1.3  4/11/88
%
export _BitchunkObject to "Builtins"

const _BitchunkObject == immutable object _BitchunkObject
  export getSignature, create

  const BitchunkType == type i_BitchunkType
    function  addr -> [Integer]
    function  getSigned[Integer, Integer] -> [Integer]
    function  getUnsigned[Integer, Integer] -> [Integer]
    function  getElement[Integer, Integer] -> [Integer]
    operation setSigned[Integer, Integer, Integer]
    operation setUnsigned[Integer, Integer, Integer]
    operation setElement[Integer, Integer, Integer]
  end i_BitchunkType

  function getSignature -> [ result : Signature ]
    result <- BitchunkType
  end getSignature

  operation create[n : Integer] -> [ r : BitchunkType ]
    r <- object aBitchunk
      export 
 	getSigned, getUnsigned, setSigned, setUnsigned, getElement,
	setElement
	
      function addr -> [r : Integer]
	primitive 319 [r] <- []
      end addr
      function getSigned [s : Integer, l : Integer] -> [ r : Integer ]
	primitive 019 [ r ] <- [ s, l ]
      end getSigned
      function getUnsigned [s : Integer, l : Integer] -> [ r : Integer ]
	primitive 119 [ r ] <- [ s, l ]
      end getUnsigned
      function getElement [s : Integer, l : Integer] -> [ r : Integer ]
	primitive 119 [ r ] <- [ s, l ]
      end getElement
      operation setSigned [start : Integer, len : Integer, val : Integer]
	primitive 219 [] <- [start, len, val]
      end setSigned
      operation setUnsigned [start : Integer, len : Integer, val : Integer]
	primitive 219 [] <- [start, len, val]
      end setUnsigned
      operation setElement [start : Integer, len : Integer, val : Integer]
	primitive 219 [] <- [start, len, val]
      end setElement
    end aBitchunk
  end create
end _BitchunkObject
